#include<stdio.h>
int seq_search(int array[],int n,int k,int seek_seq[])
{
    for (int i = 0; i < n; i++) {
        if (array[i] == k) {
            seek_seq[i] = i;
            return 0;
        } else {
            seek_seq[i] = i;
        }
    }
    return -1;
}

int bin_search(int array[],int n,int k,int seek_seq[])
{
    int low = 0;
    int high = n - 1;
    int i = 0;
    while(low <= high){
        int mid = (low + high)/2;
        int midVal = array[mid];
        if(midVal<k){
            low = mid + 1;
            seek_seq[i] = midVal;
            ++i;
        }else if(midVal>k){
            high = mid - 1;
            seek_seq[i] = midVal;
            ++i;
        }else{
            seek_seq[i] = midVal;
            ++i;;
            return 0;
        }
    }
    return -1;
}



int main(){
    int array[] = {1,2,3,4,5,6,7,8,9,10};
    int n = 10;
    int k = 8;
    int seek_seq[10];
    for (int j = 0;j<n;j++){
        seek_seq[j] = -1;
    }

    printf("查找成功时返回0，失败时返回-1。所以：最终值为:%d\n",seq_search(array,n,k,seek_seq));

    printf("查找成功时返回0，失败时返回-1。所以：最终值为:%d\n",bin_search(array,n,k,seek_seq));

}